window.onload=function () {

    initTable();

}

// function initTable(){
//     initTableHeader();
//     initTableBody();
// }
// //
// function initTableHeader(){
//
//     var list = document.getElementById('list');
//     var theader =  document.createElement('thead');
//
//     var thRow =  document.createElement('tr');
//
//     var thForName =  document.createElement('th');
//     thForName.innerText = "name";
//     var thForGender =  document.createElement('th');
//     thForGender.innerText="gender";
//     var thForDept=  document.createElement('th');
//     thForDept.innerText="dept";
//
//     thRow.appendChild(thForName);
//     thRow.appendChild(thForGender);
//     thRow.appendChild(thForDept);
//
//     theader.appendChild(thRow);
//
//     list.appendChild(theader);
//
// }

function initTable() {
    var list = document.getElementById('list');

    for (var key in employees){
        var employee = employees[key]
        var tRow = document.createElement('tr');
        for (var key2 in employee){
            if(key2!='id'){
                var tData =  document.createElement('td');
                tData.innerText = employee[key2]
                tRow.appendChild(tData);
            }
        }
        var tdForCommand = document.createElement('td');
        var btnRemove = document.createElement('button');
        btnRemove.innerText = "删除";
        btnRemove.onclick=function () {
            var currentRow = this.parentElement.parentElement;
            list.removeChild(currentRow);
        }
        tdForCommand.appendChild(btnRemove);
        tRow.appendChild(tdForCommand);
        list.appendChild(tRow);
    }

}
